<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex align-stretch benben-position-layout flex invoiceDetail_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub invoiceDetail_fd0_0'>
          <view class='flex align-center invoiceDetail_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  invoiceDetail_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex align-center'>
          </view>
          <view class='flex align-center invoiceDetail_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

      <view class="flex flex-direction align-stretch benben-flex-layout">
        <view class='flex flex-direction align-center invoiceDetail_fd1_0'>
          <text class='invoiceDetail_fd1_0_c0' v-if="dataMessage.invoice_status=='1'">开票中</text><text
            class='invoiceDetail_fd1_0_c0' v-if="dataMessage.invoice_status=='2'">已开票</text><text
            class='invoiceDetail_fd1_0_c0' v-if="dataMessage.invoice_status=='3'">发票作废</text>
          <view class='flex flex-wrap align-center'>
            <text class='invoiceDetail_fd1_0_c1_c0'>预计发票金额：￥</text>
            <text class='flex-wrap align-center invoiceDetail_fd1_0_c1_c1'>
              <text>{{ dataMessage.invoice_price | frontPrice }}</text>
              <text>{{ dataMessage.invoice_price | laterPrice }}</text>
            </text>
            <image class='invoiceDetail_fd1_0_c1_c2' mode="aspectFit" :src='STATIC_URL+"279.png"'
              @tap.stop="popupShow1661508889761=true"></image>
          </view>
        </view>
        <view class='flex flex-direction align-center invoiceDetail_fd1_1'>
          <text class='invoiceDetail_fd1_1_c0'>增值税电子普通发票</text>
          <view class='flex flex-wrap align-start invoiceDetail_fd1_1_c1'>
            <view class='flex flex-direction flex-wrap align-center invoiceDetail_fd1_1_c1_c0'>
              <image class='invoiceDetail_fd1_1_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"3.png"'></image>
              <text class='invoiceDetail_fd1_1_c1_c0_c1'>{{dataMessage.order_status}}</text>
            </view>
            <view class='flex flex-wrap align-center invoiceDetail_fd1_1_c1_c1'>
            </view>
            <view class='flex flex-direction flex-wrap align-center invoiceDetail_fd1_1_c1_c2'>
              <image class='invoiceDetail_fd1_1_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"280.png"'
                v-if="dataMessage.invoice_status=='1'"></image>
              <image class='invoiceDetail_fd1_1_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"132.png"'
                v-if="dataMessage.invoice_status=='2'"></image>
              <text class='invoiceDetail_fd1_1_c1_c2_c1'>开票完成</text>
            </view>
          </view>
        </view>
        <view class='flex flex-wrap align-center invoiceDetail_fd1_2'>
        </view>
        <view class='flex flex-direction align-stretch invoiceDetail_fd1_3'>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0'>
            <text class='invoiceDetail_fd1_3_c0_c0'>发票类型</text>
            <text class='invoiceDetail_fd1_1_c0'>电子普通发票</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0'>
            <text class='invoiceDetail_fd1_3_c0_c0'>发票内容</text>
            <text class='flex-sub invoiceDetail_fd1_3_c1_c1'>商品明细</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0'>
            <text class='invoiceDetail_fd1_3_c0_c0'>抬头类型</text>
            <text class='flex-sub invoiceDetail_fd1_3_c1_c1' v-if="dataMessage.invoice_type=='1'">个人</text><text
              class='flex-sub invoiceDetail_fd1_3_c1_c1' v-if="dataMessage.invoice_type!='1'">企业</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0'>
            <text class='invoiceDetail_fd1_3_c0_c0'>发票抬头</text>
            <text class='flex-sub invoiceDetail_fd1_3_c1_c1'>{{dataMessage.invoice_title}}</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0'
            v-if="dataMessage.invoice_type=='2' || dataMessage.invoice_status=='2'">
            <text class='invoiceDetail_fd1_3_c0_c0'>公司税号</text>
            <text class='flex-sub invoiceDetail_fd1_3_c1_c1'>{{dataMessage.invoice_company_duty_paragraph}}</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0'>
            <text class='invoiceDetail_fd1_3_c0_c0'>开票金额</text>
            <text class='invoiceDetail_fd1_3_c1_c1'>￥</text>
            <text class=' invoiceDetail_fd1_3_c5_c2'>
              <text>{{ dataMessage.invoice_price | frontPrice }}</text>
              <text>{{ dataMessage.invoice_price | laterPrice }}</text>
            </text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0' v-if="dataMessage.invoice_status=='2'">
            <text class='invoiceDetail_fd1_3_c0_c0'>开票时间</text>
            <text class='flex-sub invoiceDetail_fd1_3_c1_c1'>{{dataMessage.update_time}}</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c0' v-if="dataMessage.invoice_status=='1'">
            <text class='invoiceDetail_fd1_3_c0_c0'>申请时间</text>
            <text class='flex-sub invoiceDetail_fd1_3_c1_c1'>{{dataMessage.create_time}}</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c8' v-if="dataMessage.invoice_status=='2'">
            <text class='fu-iconfont2  invoiceDetail_fd1_3_c8_c0' @tap.stop="SavePictureFunc()">&#xe79c;</text>
            <text class='invoiceDetail_fd1_3_c8_c1' @tap.stop="SavePictureFunc()">下载发票</text>
          </view>
          <view class='flex flex-wrap align-center invoiceDetail_fd1_3_c8' v-if="dataMessage.invoice_status=='2'">
            <image class='invoiceDetail_fd1_3_c9_c0' mode="aspectFill" :src='dataMessage.invoice_img'></image>
          </view>
        </view>
      </view>


      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout invoiceDetail_flex_2">
        <view class='flex flex-wrap align-center invoiceDetail_fd2_0' v-if="dataMessage.invoice_status=='2'">
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <benben-popup v-model="popupShow1661508889761" :mask="true" :mask-close-able="true" mode='bottom'>
        <!---发票说明flex布局开始-->
        <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout invoiceDetail_flex_3">
          <view class='flex flex-wrap align-center invoiceDetail_fd3_0'>
            <view class='flex flex-wrap align-center invoiceDetail_fd3_0_c0'>
            </view>
            <image class='invoiceDetail_fd3_0_c1' mode="aspectFit" :src='STATIC_URL+"479.png"'></image>
            <text class='invoiceDetail_fd3_0_c2'>发票说明</text>
            <image class='invoiceDetail_fd3_0_c3' mode="aspectFit" :src='STATIC_URL+"480.png"'></image>
            <image class='invoiceDetail_fd3_0_c4' mode="aspectFit" :src='STATIC_URL+"281.png"'
              @tap.stop="popupShow1661508889761=false"></image>
          </view>

          <scroll-view class='invoiceDetail_fd3_1' :scroll-y='true'>
            <view class='flex flex-direction align-stretch benben-scroll flex'>
              <jyf-parser class='invoiceDetail_fd3_1_c0' :html="dataEssay.content | richTextFormat">
              </jyf-parser>
            </view>
          </scroll-view>

        </view>

        <!---发票说明flex布局结束-->

      </benben-popup>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "popupShow1661508889761": false,
        "cut": "1",
        "dataMessage": {
          "create_time": "",
          "update_time": "",
          "user_id": "",
          "order_id": "",
          "invoice_type": "",
          "invoice_title": "",
          "invoice_company_duty_paragraph": "",
          "invoice_status": "",
          "invoice_price": "",
          "invoice_mobile": "",
          "invoice_email": "",
          "invoice_img": "",
          "invoice_name": "",
          "order_status": ""
        },
        "dataEssay": {
          "aid": "",
          "name": "",
          "thumb_img": "",
          "content": "",
          "introduce": ""
        },
        "order_id": "1026"
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      /**
       * @returns 
       * Android       安卓
       * IOS       苹果
       * Web       H5 或 pc
       * Wechat       微信小程序
       * Alipay       支付宝小程序
       * Baidu       百度小程序
       * ByteBounce       抖音小程序
       * 360       360小程序
       * FastApp       快应用
       */
      appSystemIdentification() {
        return this.$store.state.appSystemIdentification
      }
    },
    watch: {},
    onLoad(options) {
      let {
        order_id
      } = options
      if (order_id !== undefined) this.order_id = order_id
      this.getDetailFunc()
      this.getMessageFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //订单-发票详情
      async getDetailFunc() {
        //请求方法
        //数据验证

        let datadataMessage = await this.$api.post(global.apiUrls.post641ed3dd595d0, {
          order_id: this.order_id
        });

        if (datadataMessage.data.code != 1) {
          this.$message.info(datadataMessage.data.msg);
          return
        }
        let infodataMessage = datadataMessage.data;
        this.dataMessage = infodataMessage.data

      },
      //系统文章--获取系统单页内容
      async getMessageFunc() {
        //请求方法
        //数据验证

        let datadataEssay = await this.$api.get(global.apiUrls.post641568f1b6f87, {
          column_id: '8'
        });

        if (datadataEssay.data.code != 1) {
          this.$message.info(datadataEssay.data.msg);
          return
        }
        let infodataEssay = datadataEssay.data;
        this.dataEssay = infodataEssay.data

      },
      //下载发票
      SavePictureFunc() {
        if (this.appSystemIdentification == 'IOS' || this.appSystemIdentification == 'Android') {
          uni.saveImageToPhotosAlbum({
            filePath: this.dataMessage.invoice_img,
            success: (res) => {
              console.log(res)
              this.$message.info(global.i18n.t('保存成功'))
              this.close()
            },
          })
        } else if (this.appSystemIdentification == 'Web') {
          uni.downloadFile({
            url: this.dataMessage.invoice_img,
            success: (res) => {
              console.log(res)
              if (res.statusCode === 200) {
                console.log('下载成功');
                var oA = document.createElement("a");
                oA.download = ''; // 设置下载的文件名，默认是'下载'
                oA.href = res.tempFilePath; //临时路径再保存到本地
                document.body.appendChild(oA);
                oA.click();
                oA.remove(); // 下载之后把创建的元素删除
              }

            }
          });
        } else if (this.appSystemIdentification == 'Wechat') {
          uni.getImageInfo({
            src: this.dataMessage.invoice_img,
            success: (res) => {
              uni.saveImageToPhotosAlbum({
                filePath: res.path,
                success: (ress) => {
                  this.$message.info(this.$t('保存成功'))
                },
                fail: (err) => {
                  console.log(err);
                  this.$message.info(this.$t('保存失败'))
                }
              })
            }
          })
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(image-path('25.png')) no-repeat;
    background-size: 100% auto;
  }

  .invoiceDetail_flex_0 {
    background: url(image-path('25.png')) no-repeat;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .invoiceDetail_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #fff;
  }

  .invoiceDetail_fd0_0_c0 {
    width: 180rpx;
  }

  .invoiceDetail_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .invoiceDetail_fd1_3_c9_c0 {
    width: 702rpx;
    height: 454rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_3_c8_c1 {
    color: var(--benbenFontColor4);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 28rpx;
  }

  .invoiceDetail_fd1_3_c8_c0 {
    font-size: 28rpx;
    font-weight: 400;
    color: var(--benbenFontColor4);
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_3_c8 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_3_c5_c2 {
    color: #333333;
    font-weight: 400;
    line-height: 42rpx;
    font-size: 28rpx;
  }

  .invoiceDetail_fd1_3_c1_c1 {
    line-height: 40rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333333;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .invoiceDetail_fd1_3_c0_c0 {
    line-height: 40rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #999999;
    width: 136rpx;
  }

  .invoiceDetail_fd1_3_c0 {
    padding: 16rpx 0rpx 16rpx 0rpx;
  }

  .invoiceDetail_fd1_3 {
    background: var(--benbenbgColor1);
    background-size: 100% auto !important;
    padding: 16rpx 24rpx 016rpx 024rpx;
  }

  .invoiceDetail_fd1_2 {
    background: var(--benbenbgColor5);
    background-size: 100% auto !important;
    height: 20rpx;
  }

  .invoiceDetail_fd1_1_c1_c2_c1 {
    line-height: 42rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_1_c1_c2 {
    margin: 0rpx 0rpx 0rpx -32rpx;
  }

  .invoiceDetail_fd1_1_c1_c1 {
    background: rgba(238, 238, 238, 1);
    height: 1rpx;
    background-size: 100% auto !important;
    width: 232rpx;
    margin: 31rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_1_c1_c0_c1 {
    line-height: 42rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #666666;
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_1_c1_c0_c0 {
    width: 48rpx;
    height: 48rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_1_c1_c0 {
    margin: 0rpx -32rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_1_c1 {
    margin: 42rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_fd1_1_c0 {
    line-height: 40rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333333;
  }

  .invoiceDetail_fd1_1 {
    background: var(--benbenbgColor1);
    border-radius: 16rpx 16rpx 0rpx 0rpx;
    background-size: 100% auto !important;
    padding: 40rpx 0rpx 32rpx 0rpx;
  }

  .invoiceDetail_fd1_0_c1_c2 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 24rpx;
  }

  .invoiceDetail_fd1_0_c1_c1 {
    line-height: 40rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #FFFFFF;
  }

  .invoiceDetail_fd1_0_c1_c0 {
    line-height: 42rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #FFFFFF;
  }

  .invoiceDetail_fd1_0_c0 {
    line-height: 43rpx;
    font-size: 32rpx;
    font-weight: 700;
    color: #FFFFFF;
    margin: 0rpx 0rpx 32rpx 0rpx;
  }

  .invoiceDetail_fd1_0 {
    background: transparent;
    padding: 32rpx 0rpx 56rpx 0rpx;
    background-size: 100% auto !important;
  }

  .invoiceDetail_flex_2 {
    background: #fff;
    background-size: 100% auto !important;
    padding: 16rpx 24rpx 16rpx 24rpx;
  }

  .invoiceDetail_fd2_0 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .invoiceDetail_flex_3 {
    background: #fff;
    background-size: 100% auto !important;
    border-radius: 24rpx 24rpx 0rpx 0rpx;
    padding: 0rpx 32rpx 64rpx 32rpx;
  }

  ::v-deep .invoiceDetail_fd3_1_c0 {
    width: 100%;
  }

  .invoiceDetail_fd3_1 {
    touch-action: none;
    height: 400rpx;
    width: 680rpx;
  }

  .invoiceDetail_fd3_0_c4 {
    width: 40rpx;
    height: 40rpx;
  }

  .invoiceDetail_fd3_0_c3 {
    width: 32rpx;
    height: 10rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx auto 0rpx 0rpx;
  }

  .invoiceDetail_fd3_0_c2 {
    margin: 0rpx 20rpx 0rpx 20rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: rgba(51, 51, 51, 1);
  }

  .invoiceDetail_fd3_0_c1 {
    width: 32rpx;
    height: 10rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .invoiceDetail_fd3_0_c0 {
    width: 26rpx;
  }

  .invoiceDetail_fd3_0 {
    line-height: 129rpx;
  }
</style>